using System.Security.Claims;

namespace JGSY.CMS.LowCode.Platform.Application.Interfaces
{
    /// <summary>
    /// JWT服务接口
    /// </summary>
    public interface IJwtService
    {
        /// <summary>
        /// 生成访问令牌
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="username">用户名</param>
        /// <param name="roles">用户角色</param>
        /// <param name="additionalClaims">额外的声明</param>
        /// <returns>访问令牌</returns>
        string GenerateAccessToken(long userId, string username, IEnumerable<string> roles, IDictionary<string, string>? additionalClaims = null);

        /// <summary>
        /// 生成刷新令牌
        /// </summary>
        /// <returns>刷新令牌</returns>
        string GenerateRefreshToken();

        /// <summary>
        /// 验证访问令牌
        /// </summary>
        /// <param name="token">访问令牌</param>
        /// <returns>验证结果和声明主体</returns>
        (bool IsValid, ClaimsPrincipal? Principal) ValidateAccessToken(string token);

        /// <summary>
        /// 从令牌中获取用户ID
        /// </summary>
        /// <param name="token">访问令牌</param>
        /// <returns>用户ID</returns>
        long? GetUserIdFromToken(string token);

        /// <summary>
        /// 检查令牌是否过期
        /// </summary>
        /// <param name="token">访问令牌</param>
        /// <returns>是否过期</returns>
        bool IsTokenExpired(string token);
    }
}
